; (function () {
    var bannerImg = document.querySelectorAll('.main-banner li');
    var bannerHd = document.querySelectorAll('.main-banner-hd li');
    var bannerImgNum = 0;
    /**
     * 计时器计时循环方法
     */
    setInterval(function () {
        banner(bannerImgNum)
        if (bannerImgNum >= bannerImg.length - 1) {
            bannerImgNum = 0;
        } else {
            bannerImgNum++;
        }
    }, 3000)

    /**
     * 切换图片
     * @param {*} num 
     */
    function banner(num) {
        bannerImg.forEach(function (item, v) {
            if (v === num) {
                item.setAttribute('class', 'active');
                bannerHd[v].setAttribute('class', 'active');
            } else {
                item.setAttribute('class', '');
                bannerHd[v].setAttribute('class', '');
            }
        })
    }
    /**
     * 遍历监听鼠标经过事件
     */
    bannerHd.forEach(function (item, v) {
        item.onmouseover = function () {
            banner(v)
            bannerImgNum = v;
        }
    })
})()


